package cn.doitedu.flink.demo;

import java.util.HashMap;
import java.util.Map;

public class Zifu {
    public static void x() {
        String x = "aaabbbccdee";
        HashMap<String, Integer> hm = new HashMap<>();
        for(char c: x.toCharArray()){
            hm.put(String.valueOf(c),hm.getOrDefault(String.valueOf(c),0)+1);
        }
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, Integer> ent : hm.entrySet()) {
            sb.append(ent.getKey()+"_"+ent.getValue()).append(":");
        }

        System.out.println(sb.toString().substring(0,sb.length()-1));
    }

    public static void y(){
        String x = "aaabbbccdee";
        char[] chars = x.toCharArray();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<chars.length;i++){
            sb.append(chars[i]).append("_");
            int num = 1;
            for(int j=i+1;j<chars.length-2;j++){
                if(chars[j] == chars[i]){
                    num++;
                    j++;
                }else{
                    i = j;
                    sb.append(num);
                    sb.append(":");
                    break;
                }
            }
        }
        System.out.println(sb.toString());
    }

    public static void main(String[] args) {
        //y();
        System.out.println(z(20));
    }

    public static int z(int n){
        if(n==1 || n==2){
            return 1;
        }else{
            return z(n-2)+z(n-1);
        }
    }
}
